<?php

/**
 * _Order filter form base class.
 *
 * @package    Porba
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class Base_OrderFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'contact_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'), 'add_empty' => true)),
      'c_order_number' => new sfWidgetFormFilterInput(),
      'status'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('StatusOrder'), 'add_empty' => true)),
      'date_recieved'  => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'date_ready'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'date_completed' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'date_due'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'ship_lastname'  => new sfWidgetFormFilterInput(),
      'ship_firstname' => new sfWidgetFormFilterInput(),
      'ship_address'   => new sfWidgetFormFilterInput(),
      'ship_zipcode'   => new sfWidgetFormFilterInput(),
      'ship_city'      => new sfWidgetFormFilterInput(),
      'ship_country'   => new sfWidgetFormFilterInput(),
      'category_name'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CategoryOrder'), 'add_empty' => true)),
      'total_price'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'created_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'contact_id'     => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Contact'), 'column' => 'id')),
      'c_order_number' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'status'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('StatusOrder'), 'column' => 'name')),
      'date_recieved'  => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'date_ready'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'date_completed' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'date_due'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'ship_lastname'  => new sfValidatorPass(array('required' => false)),
      'ship_firstname' => new sfValidatorPass(array('required' => false)),
      'ship_address'   => new sfValidatorPass(array('required' => false)),
      'ship_zipcode'   => new sfValidatorPass(array('required' => false)),
      'ship_city'      => new sfValidatorPass(array('required' => false)),
      'ship_country'   => new sfValidatorPass(array('required' => false)),
      'category_name'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('CategoryOrder'), 'column' => 'name')),
      'total_price'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'created_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('_order_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return '_Order';
  }

  public function getFields()
  {
    return array(
      'id'             => 'Number',
      'contact_id'     => 'ForeignKey',
      'c_order_number' => 'Number',
      'status'         => 'ForeignKey',
      'date_recieved'  => 'Date',
      'date_ready'     => 'Date',
      'date_completed' => 'Date',
      'date_due'       => 'Date',
      'ship_lastname'  => 'Text',
      'ship_firstname' => 'Text',
      'ship_address'   => 'Text',
      'ship_zipcode'   => 'Text',
      'ship_city'      => 'Text',
      'ship_country'   => 'Text',
      'category_name'  => 'ForeignKey',
      'total_price'    => 'Number',
      'created_at'     => 'Date',
      'updated_at'     => 'Date',
    );
  }
}
